//
//  LCMyDownloadTableViewController.m
//  JKFuYinProject
//
//  Created by jiukuyinyue on 2017/10/17.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCMyDownloadTableViewController.h"
#import "LCHistoryDetailsTableViewController+LCAVPlay.h"
#import "LCDeleteFile.h"

@interface LCMyDownloadTableViewController ()

@end

@implementation LCMyDownloadTableViewController

-(void)creareAVPlay{
    // 安装通知
    [self setupNotifications];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creareAVPlay];
    [LCHistoryDataManager sharedInstance].typeListViewStatus = LCHistoryTypeListViewStatusSongs;

}
-(void)loadData{
   self.songsData = [[[LCHistoryDataManager loadDownloadSongsData] reverseObjectEnumerator] allObjects];
    [self.tableView reloadData];
}
- (void)dealloc {
    [self teardownNotifications];
}
/// 卸载通知
- (void)teardownNotifications {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)rightBtnAction{
    
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"DOWNLOADONGS"];
    _LCPlayer.downloadData = nil;
    [self loadData];
    [LCDeleteFile deleteFileWithISHasSuffix:YES];

}

#pragma mark - 通知处理回调
///跳转到播放页
-(void)receiveNotification:(NSNotification *)notification{
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LCPlayStoryboard" bundle:nil];
    UIViewController *controller = [sb instantiateInitialViewController];
    [self presentViewController:controller animated:YES completion:nil];
    
}
- (void)setupNotifications {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:@"PUSHPLAYPAGE" object:nil];
}

@end
